package it.fuesi.synotools.fragments;

import android.annotation.TargetApi;
import android.app.Fragment;
import android.os.SystemClock;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.widget.EditText;

/**
 * Created by pascotto on 17/10/14.
 */
public abstract class BaseFragment extends Fragment {

    public abstract void onActionRefresh();

    public abstract boolean onOptionsItemSelected(MenuItem item);

    public abstract boolean onBackPressed();

    public void onOptionsMenuRefreshed(){

    }

    protected EditText getInputText(String focusText){
        final EditText edit = new EditText(getActivity());
        edit.setText(focusText);
        edit.setSelectAllOnFocus(true);

        if (android.os.Build.VERSION.SDK_INT >= 21)
            edit.setShowSoftInputOnFocus(true);
        else{
            edit.requestFocus();
            edit.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 0, 0, 0));
            edit.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP , 0, 0, 0));
        }
        return edit;
    }




}
